<template>
  <div>
    <el-form :model="form" label-width="auto" style="max-width: 600px">
    <el-form-item label="用户名">
      <el-input v-model="form.name" />
    </el-form-item>
    <el-form-item label="密码">
      <el-input v-model="form.pwd" type="password"  show-password/>
    </el-form-item>
    <el-button @click="login">登录</el-button>
    </el-form>
  </div>
</template>

<script setup lang="ts">
import axios from 'axios'
import { ref,onMounted,reactive } from 'vue'
import {ElMessage,ElMessageBox} from 'element-plus'
import { useRouter,useRoute } from 'vue-router'
const router = useRouter()
const route = useRoute()

const form=reactive({
  name:'',
  pwd:''
})

//登录
const login=()=>{
  axios.get('http://localhost:35582/api/Account/GetLogin?',{
    params:{
      name:form.name,
      pwd:form.pwd
    }
  }).then(res=>{
    if(res.data.code==100){
      ElMessage.success(res.data.message)
      router.push({name:'ShangPin'})
    }else{
      ElMessage.error(res.data.message)
      return;
    }
  }).catch(err=>{
    console.log(err);
  })
}
</script>

<style scoped>

</style>